def start(args):
    import os
    
    path, file = os.path.split(__file__)
    
    js_file = os.path.join(path, 'main.js')
    
    manager = args['bundle_manager']
    
    loader = args['loader']
    rpc = loader.get_component('rpc')
    
    wrap = loader.get_component('utils.wrap')

    @rpc.function
    def list_bundles():
        bundles = list(manager.bundles.keys())
        bundles.sort()
        return bundles

    @rpc.function
    def activate_bundle(name):
        manager.activateBundle(name)

    @rpc.function
    def stop_bundle(name):
        manager.stopBundle(name)
    
    @rpc.function
    def is_bundle_active(name):
        return manager.isBundleActive(name)
        
    @rpc.function
    def get_dependencies(name):
        return manager.getDependencies(name)
    
    
def stop(args):
    loader = args['loader']
    json = loader.get_component('web_services.json')
    json.rpc.remove_function('list_bundles')
    json.rpc.remove_function('activate_bundle')
    json.rpc.remove_function('stop_bundle')
    json.rpc.remove_function('is_bundle_active')
